package com.hex.liyue.commonmodule.utils;


import android.text.TextUtils;

import com.hex.liyue.LiYueApplication;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by yukuo on 2016/5/5.
 */
public class RegularUtils {
    //判断手机号是否正确
    public static boolean phone(String phone) {
        if (TextUtils.isEmpty(phone)){
            return false;
        }
        Matcher matcher = Pattern.compile("[1][3578]\\d{9}").matcher(phone);
        if (!matcher.matches()) {
            // 账号不匹配提示
            T.showLong(LiYueApplication.getInstance(),"请正确填写手机号");
            return false;
        } else {
            return true;
        }
    }

    //判断email格式是否正确
    public static boolean isEmail(String email) {
        String str = "([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
        Pattern p = Pattern.compile(str);
        Matcher m = p.matcher(email);
        return m.matches();
    }
}
